/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.farmcode.core.types.dao.impl;

import com.farmcode.api.types.dao.ColumnByDatabaseDAO;
import com.farmcode.api.types.model.ColumnByDatabase;
import com.farmcode.base.dao.BaseDAOImpl;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.Query;

/**
 *
 * @author oiprado
 */
@Stateless(mappedName="ejb/columnByDatabaseDAO", name="ejb/columnByDatabaseDAO")
public class ColumnByDatabaseDAOImpl extends BaseDAOImpl<ColumnByDatabase> implements ColumnByDatabaseDAO {

  @Override
  public List<ColumnByDatabase> findTypes(String database, String language) {
    String query = "select cd from ColumnByDatabase cd join cd.language l join cd.database d where UPPER(l.name) like :name and UPPER(d.name) like :dbName";
    Query result = entityManager.createQuery(query);
    result.setParameter("name", "%"+language.toUpperCase()+"%");
    result.setParameter("dbName", "%"+database.toUpperCase()+"%");
    List<ColumnByDatabase> columnByDatabases = result.getResultList();
    return columnByDatabases;
  }
  
}
